package com.one.blocks.rbac.controller.convert.worker;

import com.one.blocks.mvc.domain.Id;
import com.one.blocks.rbac.domain.RelationDomain;
import org.mapstruct.Mapping;
import org.mapstruct.Named;

import java.io.Serializable;

import static com.one.blocks.mvc.constant.MvcConstant.CONVERT_CREATE_BY;
import static com.one.blocks.mvc.constant.MvcConstant.CONVERT_CREATE_TIME;
import static com.one.blocks.mvc.constant.MvcConstant.CONVERT_ID;

/**
 * @author <a href="mailto:idler41@163.con">linfuxin</a> created on 2022-12-09 09:52:01
 */
public interface RelationDomainConvert<T extends RelationDomain & Id<? extends Serializable>, V> {
    /**
     * 添加参数转换
     *
     * @param v 前端参数对象
     * @return 数据对象
     */
    @Named("voToEntityIgnoreId")
    @Mapping(target = CONVERT_ID, ignore = true)
    @Mapping(target = CONVERT_CREATE_BY, expression = "java(SubjectHelper.getSubjectId())")
    @Mapping(target = CONVERT_CREATE_TIME, expression = "java(SubjectHelper.getAccessTime())")
    T voToEntityIgnoreId(V v);
}
